<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <base href="<? echo $this->config->config['base_url'] ?>"/>
    <title>MTP</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <meta name="Subject" content="Bine ai venit!"/>
    <link rel="icon" href="resources/icons/fam/icons/telephone.png" type="image/x-icon">

    <meta http-equiv="Cache-Control" content="no-cache"/>
    <script language="JavaScript" type="text/JavaScript" src="resources/js/libraries/jquery-1.4.2.min.js"></script>

    <style type="text/css">
        body {
            margin: 0;
            padding: 0;
            color: #5d5d5d;
            font-family: Tahoma, Arial, Verdana;
            font-size: 12px;
            background-color: #fff;
        }

        div#wrapper {
            width: 600px;
            height: 300px;
            margin-top: 100px;
        }

        div#sso-login-logo {
            width: 253px;
            height: 100px;
            float: left;
            background: url(resources/img/login/logo.png) no-repeat left center;
        }

        div#sso-login-form {
            float: left;
        }

        div#sso-login-form input {
            width: 205px;
            border: 1px solid #5d5d5d;
            padding: 0.2em 0 0.2em 0.5em;
            color: #1B4298;
            margin-top: 5px;
        }

        div#sso-login-form button.button {
            width: 59px;
            height: 27px;
            cursor: pointer;
            padding: 0;
            color: #5D5D5D;
            font-size: 13px;
            float: left;
            font-weight: bold;
            margin: 10px 5px 0 0px;
        }

        div#sso-login-form .login {
            float: left;
            padding: 0;
            margin: 0;
        }

        div#sso-login-form span.error {
            width: 200px;
            float: left;
            margin-top: 4px;
            font-size: 11px;
            color: #e70;
        }
    </style>
</head>
<body>
<center>
    <div id="wrapper">
        <div id="sso-login-logo"></div>
        <div id="sso-login-form">
            <form id="sso-login" method="post">
                <span class=login>User:</span> <br/>

                <input type="text" name="username"/>
                <input type="hidden" name="kickuser" value="0"/> <br/><br/>
                <span class=login>Parola:</span> <br/>
                <input type="password" name="password"/> <br/>

                <span class="error"></span>
                <br style="clear:both"/>

                <button type="submit" class="button" id="doFormSubmit" value="login">Start</button>
                <button style="display: none" type="button" class="button" id="doForceFormSubmit" value="Force">Da
                </button>
                <button style="display: none" type="button" class="button" id="doForceCancel" value="Force">Nu</button>

            </form>
        </div>
    </div>
</center>

<script type="text/javascript">
    jQuery(document).ready(function() {

        jQuery("#doFormSubmit").click(function() {
            jQuery('span.error').html("Asteptati...");
            return true;
        });


        fnFormSubmit = function() {
            jQuery.ajax({
                type: 'POST',
                url: 'login/xlogin',
                dataType: 'json',
                data: jQuery("#sso-login").serialize(),
                success: function(obj) {
                    if (obj.error === true) {
                        if (obj.type === 'multiplesession') {
                            jQuery('span.error').html(obj.description);
                            jQuery("#doFormSubmit").hide();
                            jQuery("#doForceFormSubmit").show();
                            jQuery("#doForceCancel").show();
                        }
                        else {
                            jQuery('span.error').html(obj.description);
                        }
                    }
                    else {
                        jQuery('span.error').html('Succes, redirectionare...');
                        window.location = jQuery('base').attr("href") + 'main';
                    }
                }
            });
            return false;
        };

        jQuery("#sso-login").submit(fnFormSubmit);
        jQuery("#doForceFormSubmit").click(function() {
            jQuery("input[name='kickuser']").val(1);
            fnFormSubmit();
            return false;
        });

        jQuery("#doForceCancel").click(function() {
            jQuery("input[name='kickuser']").val(0);
            jQuery("#doFormSubmit").show();
            jQuery("#doForceFormSubmit").hide();
            jQuery("#doForceCancel").hide();
            jQuery("#sso-login span.error").html("");
            return false;
        });
    });
</script>
</body>
